package com.suning.sawp.service.impl.job;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;

import com.google.common.collect.Maps;
import com.suning.framework.dal.client.DalClient;

/**
 * 
 * 冗余备份统计BI数据
 * 
 * @author 13071602
 *
 */
public class DBBIRedundancyJob {

    @Autowired
    DalClient dalClient;

    /**
     * 数据同步Job
     * 
     * @param saleMonth
     */
    public void synTask(String saleMonth) {
        //synCommTaskStaff(saleMonth);
        //synCommTaskStore(saleMonth);
        synCommTaskRegion(saleMonth);
        synCommTaskHQ(saleMonth);
        synRegionTaskPercent(saleMonth);
    }

    /**
     * 同步总部已完成占比
     * 
     * @param saleMonth
     */
    private void synRegionTaskPercent(String saleMonth) {
        saleMonth = StringUtils.isEmpty(saleMonth) ? new LocalDate().toString("yyyyMM") : saleMonth;
        Map<String, Object> paramMap = Maps.newHashMap();
        paramMap.put("saleMonth", saleMonth);
        dalClient.execute("BI_JOB.SynRegionTaskPercent", paramMap);
    }

    /**
     * 
     */
    @Deprecated
    private void synCommTaskStaff(String saleMonth) {
        saleMonth = StringUtils.isEmpty(saleMonth) ? new LocalDate().toString("yyyyMM") : saleMonth;
        Map<String, Object> paramMap = Maps.newHashMap();
        paramMap.put("saleMonth", saleMonth);
        dalClient.execute("BI_JOB.SynCommTaskStaff", paramMap);
    }

    /**
     * 
     */
    private void synCommTaskRegion(String saleMonth) {
        saleMonth = StringUtils.isEmpty(saleMonth) ? new LocalDate().toString("yyyyMM") : saleMonth;
        Map<String, Object> paramMap = Maps.newHashMap();
        paramMap.put("saleMonth", saleMonth);
        dalClient.execute("BI_JOB.SynCommTaskRegion", paramMap);
    }

    /**
     * 
     */
    private void synCommTaskHQ(String saleMonth) {
        saleMonth = StringUtils.isEmpty(saleMonth) ? new LocalDate().toString("yyyyMM") : saleMonth;
        Map<String, Object> paramMap = Maps.newHashMap();
        paramMap.put("saleMonth", saleMonth);
        dalClient.execute("BI_JOB.SynCommTaskHQ", paramMap);
    }

    /**
     * 
     */
    @Deprecated
    private void synCommTaskStore(String saleMonth) {
        saleMonth = StringUtils.isEmpty(saleMonth) ? new LocalDate().toString("yyyyMM") : saleMonth;
        Map<String, Object> paramMap = Maps.newHashMap();
        paramMap.put("saleMonth", saleMonth);
        dalClient.execute("BI_JOB.SynCommTaskStore", paramMap);
    }

}
